﻿//==================================================================
// Copyright (C) 2011 深圳市中旭企业管理股份有限公司
// 文件名: V_CrmDeliverHr.cs
// 作 者：代码自动生成
// 日 期：2013-1-3 10:29:58
// 描 述：
// 版 本：1.00
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容
// 1.00             
//==================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Csla;
using lite;
using Csla.Validation;
using Csla.Data;
using System.Data.SqlClient;
using ZX.DAL;
using OpenExpressApp.ORM;

namespace ZX.CRM.Library
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    [Table(Name = "V_CrmDeliverHr")]
    [ZX.DBModule.Table("V_CrmDeliverHr", "ID")]
    public class V_CrmDeliverHr : ZX.DBModule.BaseEntity
    {
        #region Business Methods 业务方法
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> IDProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("ID"));
        [DataObjectField(true, true)]
        [Column, PK]
        public Guid ID
        {
            get { return GetProperty(IDProperty); }
            set { SetProperty(IDProperty, value); }
        }

        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CodeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("Code"));
        [Column]
        public string Code
        {
            get { return GetProperty(CodeProperty); }
            set { SetProperty(CodeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> OrderProductIDProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("OrderProductID"));
        [Column]
        public Guid OrderProductID
        {
            get { return GetProperty(OrderProductIDProperty); }
            set { SetProperty(OrderProductIDProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> BeginDateProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<DateTime>("BeginDate"));
        [Column]
        public DateTime BeginDate
        {
            get { return GetProperty(BeginDateProperty); }
            set { SetProperty(BeginDateProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> PTeacherProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("PTeacher"));
        [Column]
        public string PTeacher
        {
            get { return GetProperty(PTeacherProperty); }
            set { SetProperty(PTeacherProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> ClassFrontServerProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("ClassFrontServer"));
        [Column]
        public Guid ClassFrontServer
        {
            get { return GetProperty(ClassFrontServerProperty); }
            set { SetProperty(ClassFrontServerProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> ExplainsProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("Explains"));
        [Column]
        public string Explains
        {
            get { return GetProperty(ExplainsProperty); }
            set { SetProperty(ExplainsProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> AddUserProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("AddUser"));
        [Column]
        public Guid AddUser
        {
            get { return GetProperty(AddUserProperty); }
            set { SetProperty(AddUserProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> AddTimeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<DateTime>("AddTime"));
        [Column]
        public DateTime AddTime
        {
            get { return GetProperty(AddTimeProperty); }
            set { SetProperty(AddTimeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> DliverStateProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("DliverState"));
        [Column]
        public Guid DliverState
        {
            get { return GetProperty(DliverStateProperty); }
            set { SetProperty(DliverStateProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkFlowIdProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("WorkFlowId"));
        [Column]
        public string WorkFlowId
        {
            get { return GetProperty(WorkFlowIdProperty); }
            set { SetProperty(WorkFlowIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkFlowInsIdProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("WorkFlowInsId"));
        [Column]
        public string WorkFlowInsId
        {
            get { return GetProperty(WorkFlowInsIdProperty); }
            set { SetProperty(WorkFlowInsIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkTaskIdProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("WorkTaskId"));
        [Column]
        public string WorkTaskId
        {
            get { return GetProperty(WorkTaskIdProperty); }
            set { SetProperty(WorkTaskIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkTaskInsIdProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("WorkTaskInsId"));
        [Column]
        public string WorkTaskInsId
        {
            get { return GetProperty(WorkTaskInsIdProperty); }
            set { SetProperty(WorkTaskInsIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> TypeNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("TypeName"));
        [Column]
        public string TypeName
        {
            get { return GetProperty(TypeNameProperty); }
            set { SetProperty(TypeNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> UNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("UName"));
        [Column]
        public string UName
        {
            get { return GetProperty(UNameProperty); }
            set { SetProperty(UNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> AddPmNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("AddPmName"));
        [Column]
        public string AddPmName
        {
            get { return GetProperty(AddPmNameProperty); }
            set { SetProperty(AddPmNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> ProductCodeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("ProductCode"));
        [Column]
        public string ProductCode
        {
            get { return GetProperty(ProductCodeProperty); }
            set { SetProperty(ProductCodeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> ProductNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("ProductName"));
        [Column]
        public string ProductName
        {
            get { return GetProperty(ProductNameProperty); }
            set { SetProperty(ProductNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<decimal> AmountProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<decimal>("Amount"));
        [Column]
        public decimal Amount
        {
            get { return GetProperty(AmountProperty); }
            set { SetProperty(AmountProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> UnitNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("UnitName"));
        [Column]
        public string UnitName
        {
            get { return GetProperty(UnitNameProperty); }
            set { SetProperty(UnitNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<decimal> AccountReceivableProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<decimal>("AccountReceivable"));
        [Column]
        public decimal AccountReceivable
        {
            get { return GetProperty(AccountReceivableProperty); }
            set { SetProperty(AccountReceivableProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> StudentNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("StudentName"));
        [Column]
        public string StudentName
        {
            get { return GetProperty(StudentNameProperty); }
            set { SetProperty(StudentNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<decimal> ResignMoneyProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<decimal>("ResignMoney"));
        [Column]
        public decimal ResignMoney
        {
            get { return GetProperty(ResignMoneyProperty); }
            set { SetProperty(ResignMoneyProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> PhraseTextProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("PhraseText"));
        [Column]
        public string PhraseText
        {
            get { return GetProperty(PhraseTextProperty); }
            set { SetProperty(PhraseTextProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> OrderIDProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("OrderID"));
        [Column]
        public Guid OrderID
        {
            get { return GetProperty(OrderIDProperty); }
            set { SetProperty(OrderIDProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> ProductIdProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("ProductId"));
        [Column]
        public Guid ProductId
        {
            get { return GetProperty(ProductIdProperty); }
            set { SetProperty(ProductIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> OrderCodeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("OrderCode"));
        [Column]
        public string OrderCode
        {
            get { return GetProperty(OrderCodeProperty); }
            set { SetProperty(OrderCodeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CustomerCodeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CustomerCode"));
        [Column]
        public string CustomerCode
        {
            get { return GetProperty(CustomerCodeProperty); }
            set { SetProperty(CustomerCodeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CustomerNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CustomerName"));
        [Column]
        public string CustomerName
        {
            get { return GetProperty(CustomerNameProperty); }
            set { SetProperty(CustomerNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CustomerOriginProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CustomerOrigin"));
        [Column]
        public string CustomerOrigin
        {
            get { return GetProperty(CustomerOriginProperty); }
            set { SetProperty(CustomerOriginProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CInfoerProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CInfoer"));
        [Column]
        public string CInfoer
        {
            get { return GetProperty(CInfoerProperty); }
            set { SetProperty(CInfoerProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CSalerProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CSaler"));
        [Column]
        public string CSaler
        {
            get { return GetProperty(CSalerProperty); }
            set { SetProperty(CSalerProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CTeacherProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CTeacher"));
        [Column]
        public string CTeacher
        {
            get { return GetProperty(CTeacherProperty); }
            set { SetProperty(CTeacherProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CManagerProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CManager"));
        [Column]
        public string CManager
        {
            get { return GetProperty(CManagerProperty); }
            set { SetProperty(CManagerProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CompanyProductProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CompanyProduct"));
        [Column]
        public string CompanyProduct
        {
            get { return GetProperty(CompanyProductProperty); }
            set { SetProperty(CompanyProductProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> TrainNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("TrainName"));
        [Column]
        public string TrainName
        {
            get { return GetProperty(TrainNameProperty); }
            set { SetProperty(TrainNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> CustomerTypeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("CustomerType"));
        [Column]
        public string CustomerType
        {
            get { return GetProperty(CustomerTypeProperty); }
            set { SetProperty(CustomerTypeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> CustomerIdProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("CustomerId"));
        [Column]
        public Guid CustomerId
        {
            get { return GetProperty(CustomerIdProperty); }
            set { SetProperty(CustomerIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> AddUserNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("AddUserName"));
        [Column]
        public string AddUserName
        {
            get { return GetProperty(AddUserNameProperty); }
            set { SetProperty(AddUserNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> MgrTelProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("MgrTel"));
        [Column]
        public string MgrTel
        {
            get { return GetProperty(MgrTelProperty); }
            set { SetProperty(MgrTelProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> ConsultPersonProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("ConsultPerson"));
        [Column]
        public string ConsultPerson
        {
            get { return GetProperty(ConsultPersonProperty); }
            set { SetProperty(ConsultPersonProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> ConsultPersonTelProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("ConsultPersonTel"));
        [Column]
        public string ConsultPersonTel
        {
            get { return GetProperty(ConsultPersonTelProperty); }
            set { SetProperty(ConsultPersonTelProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> EmailProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("Email"));
        [Column]
        public string Email
        {
            get { return GetProperty(EmailProperty); }
            set { SetProperty(EmailProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> IsDealEPProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("IsDealEP"));
        [Column]
        public string IsDealEP
        {
            get { return GetProperty(IsDealEPProperty); }
            set { SetProperty(IsDealEPProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> GangerTelProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("GangerTel"));
        [Column]
        public string GangerTel
        {
            get { return GetProperty(GangerTelProperty); }
            set { SetProperty(GangerTelProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> ClassNoProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("ClassNo"));
        [Column]
        public string ClassNo
        {
            get { return GetProperty(ClassNoProperty); }
            set { SetProperty(ClassNoProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> ApplicantUserProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("ApplicantUser"));
        [Column]
        public Guid ApplicantUser
        {
            get { return GetProperty(ApplicantUserProperty); }
            set { SetProperty(ApplicantUserProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> ApplicantDateProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<DateTime>("ApplicantDate"));
        [Column]
        public DateTime ApplicantDate
        {
            get { return GetProperty(ApplicantDateProperty); }
            set { SetProperty(ApplicantDateProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> TermIdProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("TermId"));
        [Column]
        public Guid TermId
        {
            get { return GetProperty(TermIdProperty); }
            set { SetProperty(TermIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> CustomeerMgrProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<Guid>("CustomeerMgr"));
        [Column]
        public Guid CustomeerMgr
        {
            get { return GetProperty(CustomeerMgrProperty); }
            set { SetProperty(CustomeerMgrProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> OrderDeptNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("OrderDeptName"));
        [Column]
        public string OrderDeptName
        {
            get { return GetProperty(OrderDeptNameProperty); }
            set { SetProperty(OrderDeptNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> TermNameProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("TermName"));
        [Column]
        public string TermName
        {
            get { return GetProperty(TermNameProperty); }
            set { SetProperty(TermNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<int> TermNumProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<int>("TermNum"));
        [Column]
        public int TermNum
        {
            get { return GetProperty(TermNumProperty); }
            set { SetProperty(TermNumProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<int> TermExistNumProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<int>("TermExistNum"));
        [Column]
        public int TermExistNum
        {
            get { return GetProperty(TermExistNumProperty); }
            set { SetProperty(TermExistNumProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> StartTimeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<DateTime>("StartTime"));
        [Column]
        public DateTime StartTime
        {
            get { return GetProperty(StartTimeProperty); }
            set { SetProperty(StartTimeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> EndTimeProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<DateTime>("EndTime"));
        [Column]
        public DateTime EndTime
        {
            get { return GetProperty(EndTimeProperty); }
            set { SetProperty(EndTimeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> IsCloseProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("IsClose"));
        [Column]
        public string IsClose
        {
            get { return GetProperty(IsCloseProperty); }
            set { SetProperty(IsCloseProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> DecisionTelProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("DecisionTel"));
        [Column]
        public string DecisionTel
        {
            get { return GetProperty(DecisionTelProperty); }
            set { SetProperty(DecisionTelProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> DecisionmakerProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("Decisionmaker"));
        [Column]
        public string Decisionmaker
        {
            get { return GetProperty(DecisionmakerProperty); }
            set { SetProperty(DecisionmakerProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> AddressProperty = RegisterProperty(typeof(V_CrmDeliverHr), new PropertyInfo<string>("Address"));
        [Column]
        public string Address
        {
            get { return GetProperty(AddressProperty); }
            set { SetProperty(AddressProperty, value); }
        }
        #endregion

        #region Validation Rules 验证规则
        //将验证规则与业务对象的属性联系在一起
        protected override void AddBusinessRules()
        {
            //AddRule的第一个参数是委托变量，也就是说是方法的变量
            ValidationRules.AddRule(CommonRules.StringRequired, "Code");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Code", 10));
            ValidationRules.AddRule(CommonRules.StringRequired, "PTeacher");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("PTeacher", 500));
            ValidationRules.AddRule(CommonRules.StringRequired, "Explains");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Explains", 200));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkFlowId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkFlowId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkFlowInsId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkFlowInsId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkTaskId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkTaskId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkTaskInsId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkTaskInsId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "TypeName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("TypeName", 100));
            ValidationRules.AddRule(CommonRules.StringRequired, "UName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("UName", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "AddPmName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("AddPmName", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "ProductCode");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("ProductCode", 10));
            ValidationRules.AddRule(CommonRules.StringRequired, "ProductName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("ProductName", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "UnitName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("UnitName", 100));
            ValidationRules.AddRule(CommonRules.StringRequired, "StudentName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("StudentName", -1));
            ValidationRules.AddRule(CommonRules.StringRequired, "PhraseText");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("PhraseText", 100));
            ValidationRules.AddRule(CommonRules.StringRequired, "OrderCode");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("OrderCode", 15));
            ValidationRules.AddRule(CommonRules.StringRequired, "CustomerCode");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CustomerCode", 15));
            ValidationRules.AddRule(CommonRules.StringRequired, "CustomerName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CustomerName", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "CustomerOrigin");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CustomerOrigin", 100));
            ValidationRules.AddRule(CommonRules.StringRequired, "CInfoer");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CInfoer", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "CSaler");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CSaler", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "CTeacher");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CTeacher", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "CManager");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CManager", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "CompanyProduct");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CompanyProduct", 100));
            ValidationRules.AddRule(CommonRules.StringRequired, "TrainName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("TrainName", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "CustomerType");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CustomerType", 100));
            ValidationRules.AddRule(CommonRules.StringRequired, "AddUserName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("AddUserName", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "MgrTel");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("MgrTel", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "ConsultPerson");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("ConsultPerson", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "ConsultPersonTel");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("ConsultPersonTel", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "Email");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Email", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsDealEP");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsDealEP", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "GangerTel");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("GangerTel", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "ClassNo");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("ClassNo", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "OrderDeptName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("OrderDeptName", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "TermName");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("TermName", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsClose");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsClose", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "DecisionTel");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("DecisionTel", 20));
            ValidationRules.AddRule(CommonRules.StringRequired, "Decisionmaker");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Decisionmaker", 30));
            ValidationRules.AddRule(CommonRules.StringRequired, "Address");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Address", 100));
            //base.AddBusinessRules();
        }
        #endregion

        #region Factory Methods 工厂方法

        public V_CrmDeliverHr() { }

        public static V_CrmDeliverHr New()
        {
            return DataPortal.Create<V_CrmDeliverHr>();
        }
        public static V_CrmDeliverHr Get(Guid ID)
        {
            return DataPortal.Fetch<V_CrmDeliverHr>(new SingleLazyCriteria<V_CrmDeliverHr, Guid>(ID, false));
        }
        public static void Delete(Guid ID)
        {
            DataPortal.Delete(ID);
        }

        #endregion

        #region Data Access 数据访问
        //由于DataPortal_create中没有对数据库的访问，所有标记了Runlocal特性，使得该方法只需在本地运行即可
        //如果代码中有访问数据库的方法，那么就不要用这个特性，使数据门户可以根据情况将此方法的运行选择在应用服务器还是本地
        [RunLocal()]
        protected override void DataPortal_Create()
        {
            //在此调用CheckRules对所有的属性进行验证规则的检查，这样检查只运行一次。
            ValidationRules.CheckRules();
        }


        //可以看到此方法没有标记任何特性
        //此方法要访问数据库所以不能标记本地，由于她没有任何数据库更新操作所以也无需事务性的保护
        //此方法调用结束后会隐含的调用MarkOld（）方法
        private void DataPortal_Fetch(Guid ID)
        {
            //通过连接字符串建立SQL连接对象，Using符号代表，范围释放的意思，SqlConnection对象会在此范围后被释放掉
            using (var ctx = ConnectionManager<SqlConnection>.GetManager(ConnectionStringNames))
            {
                IDb db = DbFactory.Instance.GetDb(ctx.Connection);
                IQuery q = db.Query();
                q.Constrain("ID").Equal(ID);

                var data = db.Select<V_CrmDeliverHr>(q)[0];
                LoadProperty(IDProperty, data.ID);
                LoadProperty(CodeProperty, data.Code);
                LoadProperty(OrderProductIDProperty, data.OrderProductID);
                LoadProperty(BeginDateProperty, data.BeginDate);
                LoadProperty(PTeacherProperty, data.PTeacher);
                LoadProperty(ClassFrontServerProperty, data.ClassFrontServer);
                LoadProperty(ExplainsProperty, data.Explains);
                LoadProperty(AddUserProperty, data.AddUser);
                LoadProperty(AddTimeProperty, data.AddTime);
                LoadProperty(DliverStateProperty, data.DliverState);
                LoadProperty(WorkFlowIdProperty, data.WorkFlowId);
                LoadProperty(WorkFlowInsIdProperty, data.WorkFlowInsId);
                LoadProperty(WorkTaskIdProperty, data.WorkTaskId);
                LoadProperty(WorkTaskInsIdProperty, data.WorkTaskInsId);
                LoadProperty(TypeNameProperty, data.TypeName);
                LoadProperty(UNameProperty, data.UName);
                LoadProperty(AddPmNameProperty, data.AddPmName);
                LoadProperty(ProductCodeProperty, data.ProductCode);
                LoadProperty(ProductNameProperty, data.ProductName);
                LoadProperty(AmountProperty, data.Amount);
                LoadProperty(UnitNameProperty, data.UnitName);
                LoadProperty(AccountReceivableProperty, data.AccountReceivable);
                LoadProperty(StudentNameProperty, data.StudentName);
                LoadProperty(ResignMoneyProperty, data.ResignMoney);
                LoadProperty(PhraseTextProperty, data.PhraseText);
                LoadProperty(OrderIDProperty, data.OrderID);
                LoadProperty(ProductIdProperty, data.ProductId);
                LoadProperty(OrderCodeProperty, data.OrderCode);
                LoadProperty(CustomerCodeProperty, data.CustomerCode);
                LoadProperty(CustomerNameProperty, data.CustomerName);
                LoadProperty(CustomerOriginProperty, data.CustomerOrigin);
                LoadProperty(CInfoerProperty, data.CInfoer);
                LoadProperty(CSalerProperty, data.CSaler);
                LoadProperty(CTeacherProperty, data.CTeacher);
                LoadProperty(CManagerProperty, data.CManager);
                LoadProperty(CompanyProductProperty, data.CompanyProduct);
                LoadProperty(TrainNameProperty, data.TrainName);
                LoadProperty(CustomerTypeProperty, data.CustomerType);
                LoadProperty(CustomerIdProperty, data.CustomerId);
                LoadProperty(AddUserNameProperty, data.AddUserName);
                LoadProperty(MgrTelProperty, data.MgrTel);
                LoadProperty(ConsultPersonProperty, data.ConsultPerson);
                LoadProperty(ConsultPersonTelProperty, data.ConsultPersonTel);
                LoadProperty(EmailProperty, data.Email);
                LoadProperty(IsDealEPProperty, data.IsDealEP);
                LoadProperty(GangerTelProperty, data.GangerTel);
                LoadProperty(ClassNoProperty, data.ClassNo);
                LoadProperty(ApplicantUserProperty, data.ApplicantUser);
                LoadProperty(ApplicantDateProperty, data.ApplicantDate);
                LoadProperty(TermIdProperty, data.TermId);
                LoadProperty(CustomeerMgrProperty, data.CustomeerMgr);
                LoadProperty(OrderDeptNameProperty, data.OrderDeptName);
                LoadProperty(TermNameProperty, data.TermName);
                LoadProperty(TermNumProperty, data.TermNum);
                LoadProperty(TermExistNumProperty, data.TermExistNum);
                LoadProperty(StartTimeProperty, data.StartTime);
                LoadProperty(EndTimeProperty, data.EndTime);
                LoadProperty(IsCloseProperty, data.IsClose);
                LoadProperty(DecisionTelProperty, data.DecisionTel);
                LoadProperty(DecisionmakerProperty, data.Decisionmaker);
                LoadProperty(AddressProperty, data.Address);
            }
        }

        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_DeleteSelf()
        {
            //依然是调用下面的方法删除的，只是他此时可以获得自己的Id
            DataPortal_Delete(IDProperty);
        }
        #endregion
    }
}

